#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;
const int N=1e5+10;
struct plane
{
	int s,t;
}a[N],b[N];
int s1[N],s2[N];
priority_queue<int>que;
inline bool cmp(plane x,plane y)
{
	return x.s<y.s;
}
int main()
{
	freopen("airport.in","r",stdin);
	freopen("airport.out","w",stdout);
	int n,m1,m2,ans=0,cnt;
	scanf("%d%d%d",&n,&m1,&m2);
	for(int i=1;i<=m1;i++) 
		scanf("%d%d",&a[i].s,&a[i].t);
	for(int i=1;i<=m2;i++) 
		scanf("%d%d",&b[i].s,&b[i].t);
	sort(a+1,a+m1+1,cmp),sort(b+1,b+m2+1,cmp);
	for(int i=1;i<=n;i++)
	{
		cnt=0; while(!que.empty()) que.pop();
		for(int j=1;j<=m1;j++)
		{
			while(!que.empty()&&-que.top()<a[j].s) que.pop();
			if(que.size()<i) cnt++,que.push(-a[j].t);
		}
		s1[i]=cnt;
		cnt=0; while(!que.empty()) que.pop();
		for(int j=1;j<=m2;j++)
		{
			while(!que.empty()&&-que.top()<b[j].s) que.pop();
			if(que.size()<i) cnt++,que.push(-b[j].t);
		}
		s2[i]=cnt;
	}
	s1[0]=s2[0]=0;
	for(int i=0;i<=n;i++)
		ans=max(ans,s1[i]+s2[n-i]);
	printf("%d\n",ans);
	return 0;
}
